<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>pgdp-quick-start-java</title>
<link rel="stylesheet" type="text/css" th:href="@{/css/index.css}" />
</head>
<body>
	<div class="body">
		<div class="tableBox">
			<div class="table">
				<div class="dzucont">
					<p class="tips">正在请求数仓你的多组学数据...</p>
					<div class="title">你的示例报告</div>
					<ul>
						<li>
							<table border='0' cellspacing='1'>
								<tr>
									<th style="width: 90px; text-align: center;">报告名称</th>
									<th>报告结果</th>
								</tr>
								<tr th:each="blogId,key : ${reportMap}"
									th:if="${not #lists.isEmpty(reportMap)}">
									<td th:text="${key.current.key}"></td>
									<td>
										<p th:text="${key.current.value}">不易胖体质，体内脂肪更容易燃烧、消耗，多运动能保持好身材。
											您看起来保持得不错，要坚持下去。</p>
									</td>
								</tr>
							</table>
						</li>
					</ul>
				</div>
			</div>
		</div>
		<div>
			<div class="title">写入数据</div>
			<div class="inputBox">
				<div class="input">
					<span>身高：</span> <input id="heightInput">
				</div>
				<div class="input">
					<span>体重：</span> <input id="weightInput">
				</div>
				<button type="button" onclick="writeData()">写入数据</button>
			</div>
		</div>
	</div>
	<script>
		function writeData() {
			var xmlhttp;
			if (window.XMLHttpRequest) {
				// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
				xmlhttp = new XMLHttpRequest();
			} else {
				// IE6, IE5 浏览器执行代码
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					var res = JSON.parse(xmlhttp.responseText);
					if(res.code == "0"){
						alert("写入数据成功");
						document.getElementById("heightInput").value = "";
						document.getElementById("weightInput").value = "";
					}
				}
			}
			xmlhttp.open("POST", "/writeData", true);
			xmlhttp.setRequestHeader("Content-type", "application/json");
			var param = {};
			param.height = document.getElementById("heightInput").value;
			param.weight = document.getElementById("weightInput").value;
			xmlhttp.send(JSON.stringify(param));
		}
	</script>
</body>
</html>

